<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	$this->_helper->layout->setLayout ( 'index' );

    }

    public function indexAction()
    {

		//
    	//$newsUrl = "http://in.news.yahoo.com/rss/cricket";
    	//$str = simplexml_load_file($newsUrl);
		//print_r($str);
		//exit;
    	//$strObj = simplexml_load_string($str);
    	


        // action body
       
    	$criteria = new Criteria();
    	$criteria->add(PlayerPeer::IS_FEATURED,'Y',Criteria::EQUAL);
    	$criteria->setLimit(5);
    	 error_reporting(E_ALL);
    	$playerRes = PlayerPeer::doSelect($criteria);
  
    	$this->view->playerRes = $playerRes;
    	
		
    	//code to get all advertising banners
    	$criteria = new Criteria();
    	$oBanner = BannerPeer::doSelect($criteria);
    	$Banner = BannerPeer::doSelectOne($criteria);
    	
    	$this->view->banner = $oBanner;
    	if(count($Banner) > 0)
    	{
    	 $this->view->singleBanner = $Banner->getPosition();
    	}
    	$position="";
    	$url = "";
    	foreach( $oBanner as $banner)
    	{
    		$position[] = "'http://localhost/cricworld/public/files/banners/".$banner->getPosition()."'";
    		$url[] ="'".$banner->getUrl()."'";
    	}
		
		$oRestaurantCnt = RestaurantPeer::doCount(new Criteria);
		
		$criteria = new  Criteria();
		$criteria->add(UserTeamPeer::CREATED_DATE,date('Y-m-d'),Criteria::EQUAL);
		$criteria->setLimit(5);
		$userTeamRes = UserTeamPeer::doSelect($criteria);
		
		$this->view->userTeamRes = $userTeamRes;
		
		
		//Sending data for view
			$this->view->position 		= $position;
			$this->view->url	  		= $url;
			//$this->view->xml 	  		= $str;
			$this->view->restaurantCnt 	= $oRestaurantCnt;		
    	
    	

    }


}

